package model

import "duoke/tables"

type ReqAccountLogin struct {
	Username string `json:"username" binding:"required" required_err:"请输入用户名/手机号"`
	Password string `json:"password" binding:"required" required_err:"请输入登录密码"`
}

// 账户信息保存
type ReqAccount struct {
	Id             int    `json:"id" xorm:"not null pk autoincr INT(10)" `
	Username       string `json:"username" binding:"required" required_err:"请输入用户名"`
	Password       string `json:"password"`
	Phone          string `json:"phone" binding:"required,len=11,numeric" required_err:"请输入手机号" len_err:"请输入正确的手机号" numeric_err:"请输入正确的手机号"`
	Name           string `json:"name"`
	Role           string `xorm:"" json:"role" form:"role" binding:"required" required_err:"请选择所属角色"`
	Nickname       string `json:"nickname"`
	Avatar         string `json:"avatar"`
	ExpireTime     int64  `json:"expire_time" binding:"required" required_err:"请选择过期时间"`
	Salt           string `json:"salt"`
	BindGoodsIds   string `xorm:"" json:"bind_goods_ids" form:"bind_goods_ids"`
	UseStorageAcid int    `xorm:"" json:"use_storage_acid"`
	CreatedAt      int    `xorm:"created" json:"created_at"`
	UpdatedAt      int    `xorm:"updated" json:"updated_at"`
	DeletedAt      int    `xorm:"deleted" json:"deleted_at"`
}

func (ReqAccount) TableName() string {
	return "account"
}

// 用户信息保存
type ReqAccountInfo struct {
	Phone    string `json:"phone" binding:"required" required_err:"请输入手机号"`
	Name     string `json:"name"`
	Nickname string `json:"nickname" binding:"required" required_err:"请输入账户名称"`
	Avatar   string `json:"avatar"`
	Password string `json:"password"`
}

// 用户基础信息
type AccountInfo struct {
	Id             int    `xorm:"not null pk autoincr INT(10)" json:"id" form:"id"`
	Username       string `json:"username"`
	Role           string `json:"role"`
	Phone          string `json:"phone"`
	Name           string `json:"name"`
	Nickname       string `json:"nickname"`
	Avatar         string `json:"avatar"`
	ExpireTime     string `json:"expire_time"`
	LastLoginIp    string `json:"last_login_ip"`
	LastLoginTime  string `json:"last_login_time"`
	CreatedAt      string `json:"created_at"`
	UseStorageAcid int    `xorm:"" json:"use_storage_acid" form:"use_storage_acid"`
}

func (AccountInfo) TableName() string {
	return "account"
}

type HomeResult struct {
	Menu    *[]tables.HomeMenu   `json:"menu"`
	Banner  *[]tables.HomeBanner `json:"banner"`
	Video   *tables.HomeVideo    `json:"video"`
	Content *tables.HomeContent  `json:"content"`
	Notice  *[]tables.HomeNotice `json:"notice"`
	Err     error                `json:"-"`
}
